package com.bluemor.reddotface.adapter;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.bluemor.reddotface.R;

/**
 ** 每页的菜单item
 */
public class ItemListAdapter extends BaseAdapter {
	private Context context = null;
	private List<Map<String, String>> list = null;
//	private List<String> list=null;
	private TextView appointmentItem =null;

	public ItemListAdapter(Context context, List<Map<String, String>> list) {
		this.context = context;
		this.list = list;
	}

	@Override
	public int getCount() {  
		return this.list.size();  
	}

	@Override
	public Object getItem(int position) {

		return this.list.get(position);
	}

	@Override
	public long getItemId(int position) {  
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.listview_appointment_items, null);
		}
		Map<String, String> map = list.get(position);
//		String text=list.get(position);
		appointmentItem = (TextView) convertView
				.findViewById(R.id.appointmentItem);
		appointmentItem.setText(map.get("text"));
//		if(Boolean.parseBoolean(map.get("flag"))){
//			appointmentItem.setBackgroundColor(Color.parseColor("#ff9a14"));
		if(map.get("flag").equals("0")){
			appointmentItem.setTextColor(Color.parseColor("#ffffff"));
		}else if(map.get("flag").equals("1")){
			appointmentItem.setTextColor(Color.parseColor("#d53838"));
		}else{
			appointmentItem.setTextColor(Color.parseColor("#404040"));
		}
//		}else{
//			appointmentItem.setBackgroundColor(Color.parseColor("#ffffff"));
//			appointmentItem.setTextColor(Color.parseColor("#000000"));
//		}
		return convertView;
	}

}
